<template>
    <div>
      <el-card shadow="always" :body-style="{ padding: '20px' }">
       <el-form  :inline="true" >
        <el-form-item label="一级分类">
            <el-select v-model="categoryStore.C1Id" @change="C1Handler" :disabled="scene!=0" >
                <el-option
                  v-for="(C1,index) in categoryStore.C1List"
                  :label="C1.name"
                  :value="C1.id"
                />
              </el-select>
        </el-form-item>
        <el-form-item label="二级分类">
            <el-select v-model="categoryStore.C2Id" @change="C2Handler" :disabled="scene!=0" >
                <el-option
                  v-for="(C2,index) in categoryStore.C2List"
                  :label="C2.name"
                  :value="C2.id"
                />
              </el-select>
        </el-form-item>
        <el-form-item label="三级分类">
            <el-select v-model="categoryStore.C3Id" :disabled="scene!=0" >
                <el-option
                  v-for="(C3,index) in categoryStore.C3List"
                  :label="C3.name"
                  :value="C3.id"
                />
              </el-select>
        </el-form-item>
       
       </el-form>
       
      </el-card>
      
    </div>
</template>

<script setup lang="ts">
import {ref,onMounted} from 'vue'
// 获取仓库
import useCategoryStore from '@/stores/category'
let categoryStore = useCategoryStore()

// 挂载完毕,通知仓库发请求
onMounted(() => {
    categoryStore. getC1List()
})

//一级分类下拉菜单的change事件：获取二级分类数据
const C1Handler = () =>{
    categoryStore.getC2List()
}
//二级分类下拉菜单的change事件：获取三级分类数据
const C2Handler = () =>{
    categoryStore.getC3List()
}

// 接收props
defineProps(['scene'])
</script>

<style scoped>

</style>